# 1. platform模块给我们提供了很多方法去获取操作系统的信息； import platform
import platform
import sys

from selenium import webdriver


class Chrome:
    def __init__(self):
        try:
            if platform.system() == 'Windows':  # 获取当前操作系统
                self.driver = webdriver.Chrome()# 声明调用浏览器Chrome
        except Exception as e:
            msg = f"打开chrome浏览器失败:{e}"
            sys.exit(msg)

    def get_driver(self):
        """获取驱动"""
        return self.driver


if __name__ == '__main__':
    import time

    driver = Chrome().get_driver()
    driver.get("http://www.baidu.com")  # 打开浏览器预设网址
    time.sleep(3)
    driver.close()  # 关闭浏览器
